﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Cl.Utils.Primitives.Class.UploadFile
{
    public class FileConfig
    {
        #region 文件上传

        /// <summary>
        /// 如果开启，则选择指定目录。不开启则默认目录；
        /// </summary>
        public bool EnableCustomFolder { get; set; } = false;

        /// <summary>
        /// 文件存储目录
        /// </summary>
        public string UploadPath { get; set; } = string.Empty;//$"D://LimsFileStorage";  //项目目录


        /// <summary>
        /// 映射目录
        /// </summary>
        public string RequestPath { get; set; } = string.Empty;//$"Upload";

        #endregion


        public string DateTimeDirectory { get; set; } = string.Empty;

        public bool Md5 { get; set; } = false;

        /// <summary>
        /// 文件最大大小
        /// </summary>
        public int MaxSize { get; set; } = 2000;

        /// <summary>
        /// 白名单
        /// </summary>
        public List<string> IncludeExtension { get; set; } = new();
        /// <summary>
        /// 黑名单
        /// </summary>
        public List<string> ExcludeExtension { get; set; } = new();

        public int UploadMaxCount { get; set; } = 5000;

        /// <summary>
        /// 判断是否是白名单数据
        /// </summary>
        /// <returns></returns>
        public bool IsWhiteTypeData(string extension)
        {
            if (GlobalService.FileConfigGlobal.IncludeExtension.Count > 0)
            {
                if (GlobalService.FileConfigGlobal.IncludeExtension.Contains(extension))
                {//包含，代表没问题
                    return true;
                }
                else
                {
                    return false;
                }
            }
            return true;
        }
    }
}
